//消息提示
export const toast = (title, success = false) => {
	if (title && typeof title === 'string') {
		if (success) {
			return new Promise(resolve=>{
				uni.showToast({
					title,
					mask:true,
					success:res=>{
						setTimeout(()=>{
							resolve(res)
						},1500)
					}
				})
			})
		} else {
			return new Promise(resolve=>{
				uni.showToast({
					title,
					mask:true,
					icon: "none",
					success:res=>{
						setTimeout(()=>{
							resolve(res)
						},1500)
					}
				})
			})
		}
	} else {
		uni.showToast({
			title: "请传入字符串",
			icon:"none"
		})
	}
}

//modal提示
export const showModal=args=>{
	return new Promise(resolve=>{
		uni.showModal({
			...args,
			success:({confirm})=>{
				resolve(confirm)
			}
		})
	})
}

export const showLoading=(title="加载中...")=>{
	uni.showLoading({
		title,
		mask:true
	})
}

export const hideLoading=()=>{
	return new Promise(resolve=>{
		uni.hideLoading()
		resolve()
	})
}

export const showActionSheet=itemList=>{
	return new Promise(resolve=>{
		uni.showActionSheet({
		    itemList,
		    success:res=>{
		        resolve(res.tapIndex + 1)
		    }
		})
	})
}